async function fetchData() {
  try {
    const response = await fetch(
      "https://official-joke-api.appspot.com/random_joke"
    );
    const data = await response.json();
    console.log(data);
    return data;
  } catch (error) {
    console.error("Error:", error);
  }
}

let btn = document.querySelector(".btn");
let newBtn = document.querySelector(".newBtn");

let content = document.querySelector(".content");
newBtn.addEventListener("click", async () => {
  newBtn.disabled = true;
  console.log(1);
  let result = await fetchData();
  content.textContent = result.setup + "\n\n" + result.punchline;
  setTimeout(() => {
    newBtn.disabled = false;
  }, 1000);
});
fetchData();
